﻿@using com.hyrentals.webcommon.extensions
@using com.hyrentals.webportal.Config
@using com.hyrentals.data
@using com.hyrentals.webportal.helpers
@using com.hyrentals.common

@model RV
@{
    Html.AddStyle("css/rv");
    Html.AddStyle("css/calendar");
    Html.AddTailScript("js/rv-detail");
    string UserId = ViewBag.UserId;
}

<div class="layout-primary rv-detail">
    <div class="layout-primary-left"></div>
    <div class="layout-primary-middle">
        <h1>@Model.DisplayName</h1>
        <div>
        @if (Model.HasCoverPhoto())
        {
            <a href="javascript:;" style="cursor: default;"><img src="@ImageHelper.GeneratePhotoUrl(Model.CoverPhotoId??"")" width="@ImageConfig.IMAGE_WIDTH_PHOTO" height="@ImageConfig.IMAGE_HEIGHT_PHOTO"/></a>
        }
        @if (Model.IsCalendarReady())
        {
            <ul>
            @if (Model.AvailableType == RVAvailabilityTypeEnum.Always)
            {
                byte index = (byte)Model.AvailableType;
                <li>@NameMapping.RVAvailabilityTypeEnumNameArray[index]</li>
            }
            else
            {
                foreach (RVAvailableDateInterval dateInterval in Model.AvailableDateIntervals)
                {
                    if (dateInterval.StartDate == dateInterval.EndDate)
                    {
                        <li>@string.Format("{0}", FormatHelper.FormatAsDate(dateInterval.StartDate))</li>
                    }
                    else
                    {
                        <li>@string.Format("{0} -> {1}", FormatHelper.FormatAsDate(dateInterval.StartDate), FormatHelper.FormatAsDate(dateInterval.EndDate))</li>
                    }
                }
            }
            </ul>
        }
        @if (Model.Pricing != null && Model.Pricing.RentalRateDaily != null)
        {
            <p>@string.Format("${0} per day", Model.Pricing.RentalRateDaily)</p>
        }
        @if (Model.IsBookReady() && UserId != Model.OwnerId)
        {
            <form id="J_BookFrom" class="valid-simple" action="" method="post">
                <input type="hidden" name="RVId" value="@Model.Id"/>
                <div class="row">
                    <label for="checkin">Check in</label>
                    <input id="checkin" class="input-text" type="text" name="checkin" autocomplete="off" data-msgbox="#msg_checkin"/>
                    <span id="msg_checkin" style="display: none;"></span>
                </div>
                <div class="row">
                    <label for="checkout">Check out</label>
                    <input id="checkout" class="input-text" type="text" name="checkout" autocomplete="off" data-msgbox="#msg_checkout"/>
                    <span id="msg_checkout" style="display: none;"></span>
                </div>
                <div class="row">
                    <span id="msg_summary" style="display: none;"></span>
                </div>
                <div class="row">
                    <a id="J_BookIt" href="javascript:void(0)" class="btn btn-large">Book It</a>
                </div>
            </form>
            
        }
        </div>
    </div>
    <div class="layout-primary-right">
    </div>
</div>